package org.oy.sealogger.ui;

import javax.swing.JFrame;

public class Screen {
	
	private JFrame frame;
	
	public Screen(JFrame frame) {
		this.frame = frame;
	}
	
	private int getFrameWidth() {
		return this.frame.getSize().width;
	}
	
	private int getFrameHeight() {
		return this.frame.getSize().height;
	}
	
	public int getItemHeight() {
		int itemHeight = (int)(Math.round(0.23 * this.getFrameHeight()));
		
		return itemHeight;
	}
	public int getSmallItemHeight() {
		int itemHeight = (int)(Math.round(0.115 * this.getFrameHeight()));
		
		return itemHeight;
	}
	public int getMediumItemHeight() {
		int itemHeight = (int)(Math.round(0.16 * this.getFrameHeight()));
		
		return itemHeight;
	}
	
	public int getYCoordinate(int number) {
		int yCoord = 0;
		
		switch(number) {
		case 1: // Compass
			yCoord = this.getFrameHeight() - this.getItemHeight();
			break;
		case 2: // Speed
			yCoord = this.getFrameHeight() - this.getItemHeight();
			break;
		case 3: // Depth
			yCoord = this.getFrameHeight() - this.getSmallItemHeight();
			break;
		case 4: // Location
			yCoord = this.getFrameHeight() - this.getSmallItemHeight();
			break;
		case 5: // Information
			yCoord = this.getFrameHeight() - this.getSmallItemHeight();
			break;
		}

		
		return (yCoord - 45);
	}
	
	public int getBoatWidth() {
		int boatW = (int)(Math.round(0.09 * this.getItemHeight()));
		
		return boatW;
	}
	public int getBoatHeight() {
		int boatH = (int)(Math.round(0.12 * this.getItemHeight()));
		
		return boatH;
	}
	public int getBoatYCoordSpace() {
		int space = (int)(this.getSmallItemHeight() - 45 + (this.getBoatHeight()/2));
		
		return space;
	}
	
	
	public int getItemWidth(int number) {
		int itemWidth = 0;
		int freeSpace = this.getFrameWidth() - this.getItemHeight();
		//int temp = (int)(Math.round(0.29 * freeSpace));
		
		switch(number) {
		case 1: // Compass
			itemWidth = this.getItemHeight();
			break;
		case 2: // Speed
			itemWidth = (int)(Math.round(0.16 * freeSpace));
			break;
		case 3: // Depth
			itemWidth = (int)(Math.round(0.16 * freeSpace));
			break;
		case 4: // Location
			itemWidth = (int)(Math.round(0.22 * freeSpace));
			break;
		case 5: // Waypoint buttons
			itemWidth = (int)(Math.round(0.62 * freeSpace));
			break;
		}
		
		return itemWidth;
	}
	
	public int getXCoordinate(int number) {
		int xCoord = 0;
		int freeSpace = this.getFrameWidth() - this.getItemHeight();
		int temp = (int)(Math.round(0.16 * freeSpace));
		int temp2 = (int)(Math.round(0.22 * freeSpace));
		
		switch(number) {
		case 1: // Compass
			xCoord = 0;
			break;
		case 2: // Speed
			xCoord = this.getItemHeight();
			break;
		case 3: // Depth
			xCoord = this.getItemHeight();
			break;
		case 4: // Location
			xCoord = this.getItemHeight() +  temp;
			break;
		case 5: // Information box
			xCoord = this.getItemHeight() +  temp + temp2;
			break;
		}		
		
		return xCoord;
	}
	
	
}
